package com.nie.orderfood.convertor;

import com.nie.orderfood.DTO.OrderMasterDTO;
import com.nie.orderfood.entity.OrderMaster;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @program: orderfood
 * @description: OrderMaster转化为OrderMasterDTO的转化器
 * @author: NieMiao
 * @create: 2018-10-11 14:36
 **/
public class OrderMaster2OrderMasterDTOConvertor {

    public static OrderMasterDTO convert(OrderMaster orderMaster) {
        OrderMasterDTO orderMasterDTO = new OrderMasterDTO();
        BeanUtils.copyProperties(orderMaster, orderMasterDTO);
        return orderMasterDTO;
    }
    public static List<OrderMasterDTO> convert(List<OrderMaster> orderMasterList){
        List<OrderMasterDTO> orderMasterDTOList = orderMasterList.stream().map(e->
                convert(e)).collect(Collectors.toList());
        return orderMasterDTOList;
    }
}
